<template>
  <div>
    <div class="inner">
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="用户名">
          <el-input v-model="form.username"></el-input>
        </el-form-item>

        <el-form-item label="密码">
          <el-input v-model="form.password"></el-input>
        </el-form-item>
      </el-form>
      <el-button type="primary" @click="Submit">登录</el-button>
    </div>
  </div>
</template>

<script>

export default {
  data() {
    return {
      form: {
        username: "",
        password: "",
      },
    };
  },
  mounted() {},
  methods: {
    Submit() {
      this.$axios
        .post("http://ceshi5.dishait.cn/admin/login", {
          username: this.form.username,
          password: this.form.password,
        })
        .then((res) => {
          console.log(res);
            alert("登陆成功")
            localStorage.setItem("token",res.data.data.token)
            this.$router.push("/shouye")
        });
    },
  },
};
</script>

<style scoped>
.el-input {
  width: 200px;
}
.inner {
  width: 400px;
  margin: 0 auto;
  text-align: center;
}
</style>